import { defineStore } from 'pinia';

/**
 * email相关信息
 */
export const useEmail = defineStore('emailInfo', {
	state: (): EmailState => {
		const curAccount = localStorage.getItem('curAccount') || '';
		return {
			currentId: '', // 当前邮件id
			sign: '',// 当前账号的邮件签名
			curAccount, // 当前账号
			curFolder: '', //当前账号的目录
			accountList: [], // 账号列表
			foldRullList: [] // 账号列表
		};
	},
	actions: {
		async setEmailId(id: string) {
			this.currentId = id;
		},
		async setSign(sign: string) {
			this.sign = sign;
		},
		async setAccount(account: string) {
			this.curAccount = account;
			localStorage.setItem('curAccount', account);
		},
		async setFolder(folder: string) {
			this.curFolder = folder;
		},
		async setAccountList(accountList: AccountItem[]) {
			this.accountList = accountList;
		},
		async setFoldRuleList(foldRullList: FoldRull[]) {
			this.foldRullList = foldRullList;
		},
	},
});
